

import 'package:basic_common/common_exports.dart';
import 'package:basic_common/global_getx.dart';

import 'model/schedules_data_list.dart';

class ServiceManagerController extends GetxController {
  final scheduListData = <SchedulesData>[].obs;

  /// 获取排版信息 1今日
  void getServerListList(int type, String doctorNo) async {
    scheduListData.value = [];
    HttpData res = await ApiService().getPaiBanList(data: {
      "teamNo": '',
      "doctorNo": doctorNo,
      "serviceTime": "",
      "timeOpt": type.toString(),
    });
    if (res.code == 1) {
      List dataList = res.data;
      if (dataList != null && dataList.length > 0) {
        dataList.forEach((item) {
          SchedulesData scheduData = SchedulesData.fromJson(item);
          scheduListData.add(scheduData);
        });
      }
      update(['scheduleList']);
    } else {
      scheduListData.value = [];
      update(['scheduleList']);
    }
  }

  /// 进入服务详情
  void navToDetail(SchedulesData itemdata) {
    Get.toNamed(AppRoutes.serverDetail, arguments: {
      "patientNo": itemdata.patientno,
      "servicePackageId": itemdata.servicepackageid.toString(),
      "teamNo": itemdata.teamno,
      "doctorNo": globalGetx.doctorInfo!=null? globalGetx.doctorInfo!.doctorNo!:'',
      "checkId": itemdata.checkid.toString()
    });
  }

  @override
  void onInit() {
    // TODO: implement onInit
    super.onInit();
    String doctorNo =globalGetx.doctorInfo!=null? globalGetx.doctorInfo!.doctorNo!:'';
    getServerListList(1, doctorNo);
  }
}
